package com.fuershiye.woman.monitor.service.impl;

import com.fuershiye.woman.monitor.beans.Page;
import com.fuershiye.woman.monitor.beans.ViewDepartIndicatorReport;
import com.fuershiye.woman.monitor.dao.DepartIndicatorDao;
import com.fuershiye.woman.monitor.model.DepartIndicator;
import com.fuershiye.woman.monitor.service.DepartIndicatorService;
import com.google.common.collect.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author admin
 */
@Service("departIndicatorService")
public class DepartIndicatorServiceImpl implements DepartIndicatorService {

    @Autowired
    private DepartIndicatorDao departIndicatorDao;

    @Override
    public DepartIndicator get(Long id){
        return departIndicatorDao.get(id);
    }
    @Override
    public void save(DepartIndicator departIndicator) {
		departIndicatorDao.save(departIndicator);
    }

	@Override
	public int updateDepart(Long fromDepartId, Long toDepartId, Long formsid, Long indicator, Integer fromyear, Integer toyear, Integer status) {
		return departIndicatorDao.updateDepart(fromDepartId, toDepartId, formsid, indicator, fromyear, toyear, status);
	}

	@Override
	public int updateDepartValue(DepartIndicator di) {
		return departIndicatorDao.updateDepartValue(di.getId(), di.getEditor(), di.getStatus(), di.getRtype(),di.getAvalue(),di.getRvalue(),di.getRshow(),di.getRemark());
	}

	@Override
	public DepartIndicator findByCondition(Long departid, Long forms, Long indicator, Integer year, Integer status) {
		return departIndicatorDao.findByCondition(departid, forms, indicator, year, status);
	}

	@Override
	public Double getValueByCondition(Long departid, Long forms, Long indicator, Integer year, Integer status) {
		return departIndicatorDao.getValueByCondition(departid, forms, indicator, year, status);
	}


	@Override
	public int countInCondition(Long departid, Long forms, Long indicator, Integer year, Integer status) {
		List<Long> departIds = Lists.newArrayList();
		departIds.add(departid);
		List<Long> indicatorIds = Lists.newArrayList();
		indicatorIds.add(indicator);
		return departIndicatorDao.countInCondition(departIds, forms, indicatorIds, year, status);
	}

	@Override
	public List<Long> listIndicatorsByCondition(List<Long> departIds, Long forms, List<Integer> years){
		return departIndicatorDao.listIndicatorsByCondition(departIds, forms, null, years, null, null);
	}

	@Override
	public List<ViewDepartIndicatorReport> listByCondition(List<Long> departIds, Long forms, List<Long> indicators, Integer year, Integer status, Page page){
		return departIndicatorDao.listInCondition(departIds, forms, indicators, year, status, page);
	}

	@Override
	public int countInCondition(List<Long> departIds, Long forms, List<Long> indicators, Integer year, Integer status){
		return departIndicatorDao.countInCondition(departIds, forms, indicators, year, status);
	}

}
